package com.example.myImpl;

import com.example.demosdk.DLFrameSDK;
import com.example.myDll.MyDllCallBack;
import com.sun.jna.Memory;
import com.sun.jna.Native;
import com.sun.jna.Pointer;
/**
 * 返回红外数据回调函数的一个实现类
 **/

public class MyDllCallbackImpl implements MyDllCallBack {

    public static final int INFRA_DATA = 0;   //16位灰度数据 调用 IFR_DoHistogramProcess、IFR_LoadInfraredData等
    public static final int INFRA_PARA = 1;   //红外参数 调用 IFR_LoadInfraredParamFromDLVStream(lHandle, pBuffer);
    public static final int INFRA_DATA_HEADER = 2;
    public static final int INFRA_PARA_HEADER = 3;
    @Override
    public void fInfraDataCallBack(long lHandle, long dwDataType, Pointer pBuffer, long dwBufSize){
//        long INFRA_DATA = dwDataType;
        int tDataType = (int) dwDataType;
        switch (tDataType){
            case INFRA_DATA:
                System.out.println("16位灰度数据");
                int tagHandle = (int) lHandle;
                Pointer temValue = new Memory(200);  //应该为INT8U *InfraredData  unsigned char
                DLFrameSDK dlFrameSDK = (DLFrameSDK) Native.loadLibrary("static/Demo/InfraredSDK",DLFrameSDK.class);
                dlFrameSDK.IFR_LoadInfraredData(tagHandle,temValue);
                System.out.println("temValue的值"+temValue);//指针变量
//        Native.free(Pointer.nativeValue(temValue));  //手动释放内存
//        Pointer.nativeValue(temValue,0);
            case INFRA_PARA:
                System.out.println("红外参数");

        }


    }
}
